package com.spring.demo2;

import org.springframework.context.support.AbstractApplicationContext;
import org.springframework.context.support.FileSystemXmlApplicationContext;

public class MainApp {

	/**
	 * 指定父bean继承
	 */
	public void testDemo2(){
		AbstractApplicationContext context = new FileSystemXmlApplicationContext("src/test/resources/bean2.xml");
		HelloWorld objA = (HelloWorld) context.getBean("helloWorld1");
		objA.getMessage1();
		objA.getMessage2();
		HelloIndia objB = (HelloIndia) context.getBean("helloIndia1");
		objB.getMessage1();
		objB.getMessage2();
		objB.getMessage3();
	}
	/**
	 * 指定模板bean继承
	 */
	public void testDemo3(){
		AbstractApplicationContext context = new FileSystemXmlApplicationContext("src/test/resources/bean2.xml");
		HelloIndia objB = (HelloIndia) context.getBean("helloIndia2");
		objB.getMessage1();
		objB.getMessage2();
		objB.getMessage3();
	}
	public static void main(String[] args) {
		new MainApp().testDemo2();
		System.out.println("=========================");
		new MainApp().testDemo3();
	}
}
